Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Set proper versionCode and versionName #2398

Merged
merged 4 commits into from
Feb 26, 2022

Conversation

hoffie
Copy link
Member

@hoffie hoffie commented Feb 16, 2022

Short description of changes

  • Autobuild: Allow overriding checkout's fetch-depth
  • Android: Set ANDROID_VERSION_{CODE,NAME}
    • android/AndroidManifest.xml uses specific macros (%%INSERT_VERSION...). Those macros are replaced by the ANDROID_VERSION_* qmake variables, which were previously unset and therefore defaulted to "1". This made it impossible to update the APK without uninstalling first according to Android: Package update installation fails #1760. This commit populates these variables.
    • The user-visible ANDROID_VERSION_NAME is set similar to VERSION for other platforms.
    • The Android-internal ANDROID_VERSION_CODE is set to the number of git commits in the current branch. This seems to be the most straightforward solution which guarantees unique, increasing integers within the scope of the master branch. Feature branches will break this logic, so developers may still be required to uninstall/reinstall.
    • In order to get the commit count, the autobuild Android logic had to be modified to fetch the repo in full depth instead of only the most-recent commit.
    • Tested via apktool d and by checking apktool.yml.
  • Jamulus.pro: Move ANDROID_ABIS to conditional (The variable was set globally, but is only required for the Android target. Git history does not show a specific reason for placing it globally (a3558aa).)
  • Jamulus.pro: Use DISTFILES for AndroidManifest.xml

Context: Fixes an issue?

Related #1760 (but doesn't fix, it seems)

Does this change need documentation? What needs to be documented and how?

No.
CHANGELOG: Android: Package version has been fixed to show the actual release version.

Status of this Pull Request

Ready.

What is missing until this pull request can be merged?

Can be merged after 3.8.2.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want (via apktool)
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@hoffie hoffie added this to the Release 3.9.0 milestone Feb 16, 2022
@hoffie
Copy link
Member Author

hoffie commented Feb 16, 2022

@NickHyHo Can you confirm that this PR fixes your issue? You can get the APK from the "Checks" listed above.
@ann0see Were you able to reproduce the issue with previous APKs? Can you confirm that the APK from this PR works better?

@NickHyHo
Copy link

@hoffie First, a Government Health Warning: My coding days are long (30+ years!) gone, and my training/experience on GitHub is zilch, but here goes... Managed to find an APK "3.8.2rc1dev-c50f092 (1)" which I installed ok, but I have a feeling that it made itself at home as a brand new package... so I then found APK "3.8.2rc1dev-26b235b0 (4749)" hot off the press, attempted to install, got "This package is already installed ... {2x package details} ... Do you want to install the update", so I did attempt install, but got "App not installed as package conflicts with an existing package." It's now a bit late here (UK) so I won't try to untangle myself until tomorrow... Since I'm junior at GitHub, please could you point me directly to the APK you'd like me to try, I'll then clear down, install the official Jamulus build, put some settings in (so I know if they're maintained during update!), then try to install your new APK on top... Or another process if you wish!

@NickHyHo
Copy link

@hoffie Doh! I used wrong device last night (2 similar phones, tired person, any excuse...). This morning I used the correct device, attempted install of 3.8.2rc1dev-26b235b0 (4749) over 3.8.0, but it still ended with "App not installed". I don't know if I used the correct Release Candidate, but my erroneous work last night might suggest that there's still a problem anyway?

@pljones
Copy link
Collaborator

pljones commented Feb 17, 2022

I don't know if I used the correct Release Candidate, but my erroneous work last night might suggest that there's still a problem anyway?

The assets from the latest run are here (as far as I can tell...):
https://github.com/jamulussoftware/jamulus/actions/runs/1855822646

It looks like that's the one you used.

@NickHyHo
Copy link

@pljones Thanks yes, that's the one, so I think it's not quite fixed yet...

@hoffie
Copy link
Member Author

hoffie commented Feb 17, 2022

@NickHyHo Thanks for testing. So this PR doesn't seem to be enough to fix the issue. I still believe it's right and improves things (we were always version 1 before that PR), but there's no hurry in getting it merged. I'm leaving it open for merge after 3.8.2.
I think we should move further debugging to #1760 again.

@hoffie hoffie force-pushed the autobuild/set-android-version branch from 4920476 to 967b57b Compare February 17, 2022 22:59
@hoffie hoffie force-pushed the autobuild/set-android-version branch from 967b57b to e61419b Compare February 20, 2022 22:58
@hoffie hoffie requested review from ann0see and softins February 20, 2022 23:02
@ann0see
Copy link
Member

ann0see commented Feb 21, 2022

Unfortunately I don’t have access to the Android device anymore.

@ann0see ann0see removed their request for review February 21, 2022 06:46
Copy link
Member

@softins softins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, but I'd like to try an installation, and maybe even a build myself.

@@ -168,6 +169,7 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: ${{ matrix.config.checkout_fetch_depth || '1' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the checkout_fetch_depth: '0' further up evaluate here as false or true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found explicit documentation, but the CI confirms that it does what it should: Android uses a full checkout while the other targets (e.g. Linux) only fetch the most recent commit:

Therefore, I assume that '0' as a non-empty string evaluates to true (probably like Python).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore, I assume that '0' as a non-empty string evaluates to true (probably like Python).

And unlike Perl and PHP!

ANDROID_ABIS = armeabi-v7a arm64-v8a x86 x86_64
ANDROID_VERSION_NAME = $$VERSION
ANDROID_VERSION_CODE = $$system(git log --oneline | wc -l)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see in the build log where these get used. If they are used silently, then perhaps they could be echoed too?

Copy link
Member Author

@hoffie hoffie Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, they're qmake-internal variables. I've added a message() call to output them now.

Copy link

@NickHyHo NickHyHo Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried installing jamulus_3.8.2dev-5f108fd_android.apk over 3.8.0 ... result is as before, i.e. version number is reported as being different (see screenshot attached), but install ends with message "App not installed". I suspect this is "as expected" at the moment! BTW, if you want me to check any functionality on any new build let me know - I have several Android devices at my disposal, and can force a new build to install by uninstalling any old one, of course.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, first time I've posted an image - didn't realise it'd come out that big on screen!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've edited your comment to use <img src="...existing url.." width="2002>to reduce the size a bit.

result is as before, i.e. version number is reported as being different (see screenshot attached)
but install ends with message "App not installed". I suspect this is "as expected" at the moment!

Thanks for the screenshot. Yes, seeing the real version number here is definitely an improvement. And yes, it's expected that this PR does not solve all update problems on Android. While I had hoped for this to be the case, the PR doesn't claim to do it :)

BTW, if you want me to check any functionality on any new build let me know - I have several Android devices at my disposal, and can force a new build to install by uninstalling any old one, of course.

Great, thanks! I'll likely ask again as part of #2404.

android/AndroidManifest.xml uses specific macros
(%%INSERT_VERSION...). Those macros are replaced by the
ANDROID_VERSION_* qmake variables, which were previously unset and
therefore defaulted to "1". This made it impossible to update the
APK without uninstalling first.

This commit populates these variables. The user-visible
ANDROID_VERSION_NAME is set similar to VERSION for other platforms.
The Android-internal ANDROID_VERSION_CODE is set to the number of git
commits in the current branch. This seems to be the most straightforward
solution which guarantees unique, increasing integers within the scope
of the master branch. Feature branches will break this logic, so
developers may still be required to uninstall/reinstall.

In order to get the commit count, the autobuild Android logic had to be modified
to fetch the repo in full depth instead of only the most-recent commit.

Tested via `apktool d` and by checking `apktool.yml`.

Related: jamulussoftware#1760
The variable was set globally, but is only required for the Android
target.
Git history does not show a specific reason for placing it globally
(a3558aa).
@hoffie hoffie force-pushed the autobuild/set-android-version branch from e61419b to 079a52a Compare February 21, 2022 23:10
@hoffie
Copy link
Member Author

hoffie commented Feb 26, 2022

@ann0see @softins IMO we could merge this soon. Android is still experimental and both apktool and @NickHyHo's tests/screenshot show that the version handling seems to have been improved with this PR. I think the chance that this PR makes anything worse is rather low. We should have a close look at the Autobuild fetch depth change, but there are at least logs which show that it works as expected.

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it at the moment, but I think it's ok.

Copy link
Member

@softins softins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look ok, and I was able to install the apk on my phone. Settings:Apps reports the correct version number, and I can run the app. Some issues in the app itself to address, but they are not related to this PR, so can be investigated separately.

@hoffie hoffie merged commit 6117258 into jamulussoftware:master Feb 26, 2022
@hoffie hoffie deleted the autobuild/set-android-version branch February 26, 2022 18:18
@ann0see
Copy link
Member

ann0see commented Jul 25, 2022

@pljones and another fix (prefixed with Android: now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants